package 曾世昌12_8.zuoye14;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;

public class test {
    public static void main(String[] args) throws Exception {
        List<String> string = FileUtils.readLines( new File( "E:\\untitled5\\src\\rc\\mxdx3_zhoumozuoye\\zuoye14\\data.properties" ), "utf-8" );
        Class<?> aClass = Class.forName( "rc.mxdx3_zhoumozuoye.zuoye14.User" );
        Method setId = aClass.getDeclaredMethod( "setUid", String.class);
        setId.setAccessible( true );
        Method setname = aClass.getDeclaredMethod( "setUsername", String.class);
        setId.setAccessible( true );
        Method setge = aClass.getDeclaredMethod( "setPassword", String.class);
        setId.setAccessible( true );
        Constructor<?> constructor = aClass.getConstructor();
        Object o = constructor.newInstance();
        List<String> strings = FileUtils.readLines( new File( "E:\\untitled5\\src\\rc\\mxdx3_zhoumozuoye\\zuoye14\\data.properties" ), "utf-8" );
        for (int i = 0; i < strings.size(); i++) {
            String[] split = strings.get( i ).split( "=" );
            for (int i1 = 0; i1 < split.length; i1++) {
                if (split[0].equals( "uid" )) {
                    setId.invoke( o, split[1] );
                }
                if (split[0].equals( "username" )) {
                    setname.invoke( o, split[1] );
                }
                if (split[0].equals( "password" )) {
                    setge.invoke( o, Integer.parseInt( split[1] ) );
                }
            }
        }
        Method toString = aClass.getDeclaredMethod( "toString" );
        toString.setAccessible( true );
       toString.invoke( o,null );
    }
}

